<?php

class HTML_Image extends HTML implements HTMLElements {
	private $attributeAlt;
	private $attriubteSrc;
	
	const HTML_IMAGE = 'img';
	const ATTRIBUTE_ALT = 'alt';
	const ATTRIBUTE_SRC = 'src';
	
/**
	 * 
	 * This function creates a complete Link-Element.
	 * The attributes have to be passed within an array. Possible attributes are:
	 * 	- $class
	 * 	- $id
	 * 	- $title
	 *  - $alt
	 *  - $src
	 * @param unknown_type $parent
	 * @param String[][] $properties
	 */
	public function __construct($parent, $properties)  {
		PropertySetter::setProperties($this, $properties);
		$parent->addChildElement($this);
	}
	
	public function setAttributeAlt ($alt)  {
		$this->attributeAlt = $alt;
	}
	
	public function setAttributeSrc ($src)  {
		$this->attributeSrc = $src;
	}
	
	public function getAttributeAlt ()  {
		return $this->attributeAlt;
	}
	
	public function getAttributeSrc ()  {
		return $this->attributeSrc;
	}
	
	public function getImageAttributes ()  {
		
		$output = '';
		
		if (!empty($this->attributeSrc))  {
			$output .= ' '. self::ATTRIBUTE_SRC. '="'. $this->getAttributeSrc(). '"';
		}
		if (!empty($this->attributeAlt))  {
			$output .= ' '. self::ATTRIBUTE_ALT. '="'. $this->getAttributeAlt(). '"';
		}
		
		if ($output == '')  {
			$output = ' ';
		}
		
		return $output;
		
	}
	
	public static function getAttributes ()  {
		$attributes = array();
		$parentAttributes = parent::getAttributes();
		$attributes[] = self::ATTRIBUTE_ALT;
		$attributes[] = self::ATTRIBUTE_SRC;
		
		return array_merge($parentAttributes, $attributes);
	}
	
	public function toString ()  {
		$output = '<'. self::HTML_IMAGE.
					$this->getHTMLAttributes().
					$this->getImageAttributes(). '/>';
		
		return $output;
	}
	
}
?>